<template>
  <div id="app" style="margin-bottom: 200px">
    <el-row :span="24" type="flex">
      <el-col :span="5"><h3>工艺阶段</h3></el-col>
    </el-row>
    <el-divider style="margin: 10px"></el-divider>
    <el-steps :space="200" :active="2" finish-status="success" style="margin: 20px auto">
      <el-step title="售前"></el-step>
      <el-step title="立项"></el-step>
      <el-step title="工艺"></el-step>
      <el-step title="设计"></el-step>
      <el-step title="制造"></el-step>
      <el-step title="交付"></el-step>
      <el-step title="售后"></el-step>
      <el-step title="归档"></el-step>
    </el-steps>

    <el-form ref="form" :model="craftForm" label-width="100px">

      <el-form-item label="负责人">
        <el-input disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="计划时间">
        <el-date-picker
            v-model="planTime"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="实际时间">
        <el-date-picker
            v-model="realityTime"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="">
        <el-table :data="craftTable">

          <el-table-column label="序号" width="100px" header-align="center">
            <template slot-scope="scope">
              <el-input :value="scope.$index + 1" disabled="true"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="试验类别" header-align="center">
            <el-input v-model="craftType"></el-input>
          </el-table-column>
          <el-table-column label="试验内容" header-align="center">
            <el-input v-model="craftContent"></el-input>
          </el-table-column>
          <el-table-column label="试验结果" header-align="center">
            <el-input v-model="craftResult" ></el-input>
          </el-table-column>
          <el-table-column>
            <el-upload
                class="upload-demo"
                action="https://jsonplaceholder.typicode.com/posts/"
                :on-preview="handlePreview"
                :on-remove="handleRemove"
                :before-remove="beforeRemove"
                multiple
                :limit="3"
                :on-exceed="handleExceed"
                :file-list="fileList">
              <el-button size="small" type="text">上传文件</el-button>
            </el-upload>
          </el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button @click="addcraftItem()" type="text">增加</el-button>
              <el-button @click="deletecraftItem()" type="text">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" size="mini" @click="submit()">提交审批</el-button>
        <el-button type="primary" size="mini">取消</el-button>
      </el-form-item>
    </el-form>

  </div>
</template>

<script>
export default {
  name: "EquipmentTech",
  data() {
    return {
      fileList:[],
      craftForm: {
        planTime: '',
        realityTime: '',
      },
      craftTable: [
        {craftSn: '', craftType: '', craftContent: '', craftResult: ''}
      ]
    }
  },
  methods: {
    submit() {
      location = "design"
    },
    addcraftItem() {
      const newCraftRow = {craftSn: '', craftType: '', craftContent: '',craftResult:''}
      this.craftTable.push(newCraftRow)
    },
    deletecraftItem() {
      if (this.craftTable.length !== 1)
        this.craftTable.pop()
    },
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePreview(file) {
      console.log(file);
    },
    handleExceed(files, fileList) {
      this.$message.warning(`当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`);
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${ file.name }？`);
    }
  }
}
</script>

<style scoped>

</style>